#include<bits/stdc++.h>
using namespace std;
const double fl=1e-4;
const int N=1e6+700,M=1e5+700;
unordered_map<int,int>mp;
int l[N],jd[M],v[M],a[M],st[M];
struct Node{
    int ll,rr;
}osp[M];
inline int rlst(int x,int V){return int((V*V-v[x]*v[x])/2.0/a[x]+1);}//a>0
inline int dlst(int x,int V){return int((v[x]*v[x]-V*V)/2.0/(-a[x])-fl);}//a<0
bool cmp(Node x,Node y){return x.ll<y.ll;}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T;cin>>T;
    while(T--){
        int n,m,L,V,ans=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;++i)cin>>st[i]>>v[i]>>a[i];
        for(int i=1;i<=m;++i)cin>>jd[i];
        for(int i=1;i<=m;++i)mp[jd[i]]=i;
        int minm=1;
        for(int i=0;i<=L;++i){
            if(i<=jd[minm])l[i]=jd[minm];
            else l[i]=jd[++minm];
        }
        int k=0;bool bl=0;
        for(int i=1;i<=n;++i){
            if((a[i]==0&&v[i]<=V)||(a[i]>0&&(V*V-v[i]*v[i])/2.0/a[i]>=jd[m]-st[i])||st[i]>jd[m])continue;
            if(a[i]==0)++ans;//,osp[ans].ll=mp[l[st[i]]],osp[ans].rr=m
            else if(a[i]>0)ans++;//,osp[ans].ll=mp[l[st[i]+rlst(i,V)]],osp[ans].rr=m
            //else{
            //    int k1=mp[l[st[i]]],k2=mp[l[st[i]+dlst(i,V)]];
            //    if(k1==k2&&st[i]+dlst(i,V)<jd[k2])continue;
            //    ans++,bl=1,osp[ans].ll=k1,osp[ans].rr=k2;
            //}
        }
        cout<<ans<<' ';
        if(ans==0){cout<<m<<'\n';continue;}
        if(!bl)cout<<m-1<<'\n';
        //else{
         //   sort(osp+1,osp+1+ans,cmp);
        //   int cnt=0,minr=0x3f3f3f3f;
         //   for(int i=1;i<=n;++i){
         //       if(minr>osp[i].ll)minr=min(minr,osp[i].rr);
         //       else {++cnt,minr=osp[i].rr;}
         //   }
         //   cout<<m-cnt<<'\n';
        //}
    }
    return 0;
}
